Skip to content

fix: convert numpy types to Python native in predictions#406

Open
Abiram08 wants to merge 2 commits intosktime:mainfrom
Abiram08:fix/bugs
Open

fix: convert numpy types to Python native in predictions#406
Abiram08 wants to merge 2 commits intosktime:mainfrom
Abiram08:fix/bugs

Conversation

@Abiram08
Copy link
Copy Markdown

Reference Issues/PRs

Fixes #401

What does this implement/fix? Explain your changes.

Fixes an issue where fit_predict returned numpy.float64 values, which caused JSON serialization failures in MCP responses.

Changes in executor.py:

  • pd.Series: Convert values using float(v) if hasattr(v, "dtype")
  • pd.DataFrame: Convert nested values with list comprehension
  • Uses hasattr(v, "dtype") to detect numpy types without importing numpy

Does your contribution introduce a new dependency?

No.

What should a reviewer concentrate their feedback on?

  • Whether using hasattr(v, "dtype") is the right approach for detecting numpy types
  • If the float() conversion handles all edge cases correctly

Any other comments?

Added test_numpy_serialization.py verifying predictions are JSON serializable.

PR checklist

  • I've added unit tests and made sure they pass locally
  • I've added myself to the list of contributors

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] numpy.float64 values in prediction results cause JSON serialization failure

1 participant